<!DOCTYPE html>
<html class="x-admin-sm">

<head>
<meta charset="UTF-8">
<title>欢迎页面-X-admin2.2</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
<link rel="stylesheet" href="../../css/font.css">
<link rel="stylesheet" href="../../css/xadmin.css">
<script type="text/javascript" src="../../lib/layui/layui.js"></script>
<script type="text/javascript" src="../../js/xadmin.js"></script>
<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
<!--[if lt IE 9]>
            <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
            <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
</head>

<body>
	<div class="layui-fluid">
		<div class="layui-row">
			<form class="layui-form">
				<div class="layui-form-item">
					<label for="teacode" class="layui-form-label"> <span
						class="x-red">*</span>茶室
					</label>
					<div class="layui-input-inline">
						<select id="teacode" name="teacode" class="valid">
							<option value="BJ0001">麒麟社店</option>
						</select>
					</div>
					<div class="layui-form-mid layui-word-aux">
						<span class="x-red">*</span>
					</div>
				</div>
				<div class="layui-form-item">
					<label for="time0" class="layui-form-label"> <span
						class="x-red">*</span>预定时段
					</label>
					<div class="layui-input-inline">
						<input type="text" class="layui-input" id="time0" name="time0" lay-verify="title"
							required="required" placeholder="HH:mm">
					</div>
					<div class="layui-form-mid layui-word-aux">
						<span class="x-red">*</span>
					</div>
				</div>
				<div class="layui-form-item">
					<label for="time1" class="layui-form-label"> <span
						class="x-red">*</span>开始时间
					</label>
					<div class="layui-input-inline">
						<input type="text" class="layui-input" id="time1" name="time1" lay-verify="title"
							required="required" placeholder="yyyy-MM-dd HH:mm:ss">
					</div>
					<div class="layui-form-mid layui-word-aux">
						<span class="x-red">*</span>
					</div>
				</div>
				<div class="layui-form-item">
					<label for="time2" class="layui-form-label"> <span
						class="x-red">*</span>结束时间
					</label>
					<div class="layui-input-inline">
						<input type="text" class="layui-input" id="time2" name="time2" lay-verify="title"
							required="required" placeholder="yyyy-MM-dd HH:mm:ss">
					</div>
					<div class="layui-form-mid layui-word-aux">
						<span class="x-red">*</span>
					</div>
				</div>
				<div class="layui-form-item">
					<label for="serno" class="layui-form-label"> <span
						class="x-red">*</span>订单号
					</label>
					<div class="layui-input-inline">
						<input type="text" id="serno" name="serno" readonly="readonly"
							class="layui-input">
					</div>
					<div class="layui-form-mid layui-word-aux">
						<span class="x-red">*</span>
					</div>
				</div>
				<div class="layui-form-item">
                    <label for="mt_code" class="layui-form-label"> <span
                        class="x-red">*</span>验证码
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="mt_code" name="mt_code"  lay-verify="title"
                            class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>
                    </div>
                </div>
				<div class="layui-form-item">
					<label for="price" class="layui-form-label"> <span
						class="x-red">*</span>订单金额
					</label>
					<div class="layui-input-inline">
						<input type="number" id="price" name="price"  lay-verify="title"
                            class="layui-input">
					</div>
					<div class="layui-form-mid layui-word-aux">
						<span class="x-red">*</span>
					</div>
				</div>
				<div class="layui-form-item">
					<label for="total" class="layui-form-label"> <span
						class="x-red">*</span>累计时长
					</label>
					<div class="layui-input-inline">
					    <select id="total" name="total" class="valid">
                            <option value="2">2H</option>
                            <option value="2.5">2.5H</option>
                            <option value="3">3H</option>
                            <option value="3.5">3.5H</option>
                            <option value="4">4H</option>
                            <option value="4.5">4.5H</option>
                            <option value="5">5H</option>
                            <option value="5.5">5.5H</option>
                            <option value="6">6H</option>
                        </select>
					</div>
					<div class="layui-form-mid layui-word-aux">
						<span class="x-red">*</span>
					</div>
				</div>
				<div class="layui-form-item">
					<label for="status" class="layui-form-label"> <span
						class="x-red">*</span>订单状态
					</label>
					<div class="layui-input-inline">
						<select id="status" name="status" class="valid">
							<option value="已支付">已支付</option>
						</select>
					</div>
					<div class="layui-form-mid layui-word-aux">
						<span class="x-red">*</span>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label"></label>
					<button class="layui-btn" lay-filter="add" lay-submit="">增加</button>
				</div>
			</form>
		</div>
	</div>
	<script>
		layui.use([ 'form', 'layer', 'laydate' ], function() {
			$ = layui.jquery;
			var form = layui.form, layer = layui.layer;
			var laydate = layui.laydate;

			$("#serno").val("MTL" + new Date().getTime());

			//时间范围
			laydate.render({
				elem : '#time0',
				type : 'time',
				range : true,
				format : 'HH:mm'
			});
			//日期时间选择器
			laydate.render({
				elem : '#time1',
				type : 'datetime'
			});
			//日期时间选择器
			laydate.render({
				elem : '#time2',
				type : 'datetime'
			});

			//自定义验证规则
			form.verify({
                title : function(value) {
                	console.log(value.length);
                    if (value.length < 1) {
                        return '不能为空';
                    }
                }
            });

			//监听提交
			form.on('submit(add)', function(data) {
				console.log(data.field);
				$.ajax({
					url : '../../addMTOrder',
					data : data.field,
					success : function(data) {
                        if (data.isSuccessflag) {
                        	// 获得frame索引
                            var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            parent.layer.close(index);
                        } else {
                            layer.alert(data.message, {
                                icon: 5,
                                title: "提示"
                            });
                        }
					},
                    error : function(data) {
                        layer.alert('系统异常!', {
                            icon: 5,
                            title: "提示"
                        });
                    }
				});
				return false;
			});
		});
	</script>
</body>

</html>